package com.hxzy.front.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;


@Controller
public class DemoController {

    // ModelAndView
    @GetMapping(value = "/freemarker/demo01")
    public String  demo(Model  model){

        model.addAttribute("user","这是一个使用freemarker技术");

        //使用Map ${latestProduct.url}">${latestProduct.name}
        Map<String,Object> data=new HashMap<>();
        data.put("url","http://www.jd.com");
        data.put("name","京东商城");

        model.addAttribute("latestProduct",  data);
        //视图= 模板路径template-loader-path(classpath:/templates/)+ 前缀(prefix) +  视图名  后缀freemarker.suffix(.ftl)
        return "demo";        
    }
}
